<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>websocket测试</title>
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <style type="text/css">
        h3,h4{
            text-align:center;
        }
    </style>
</head>
<body>

<h3>WebSocket测试，客户端接收到的消息如下：</h3>

<textarea id = "messageId" readonly="readonly" cols="150" rows="30" >

</textarea>


<script crossorigin="anonymous"  src="https://lib.baomitu.com/socket.io/2.3.0/socket.io.js" type="application/javascript"></script>

<script>
    $(function(){
        var socket = io.connect('http://127.0.0.1:9092', {
            'force new connection': true,
            'reconnection': true,
            'reconnectionDelay': 2000,                  // starts with 2 secs delay, then 4, 6, 8, until 60 where it stays forever until it reconnects
            'reconnectionDelayMax': 5000,               // 1 minute maximum delay between connections
            'reconnectionAttempts': 10,         // to prevent dead clients, having the user to having to manually reconnect after a server restart.
            'timeout': 10000,                           // before connect_error and connect_timeout are emitted.
            'transports': ['websocket', 'polling']
        });

        socket.on("message", function(data){
            console.log(data);
            $('#messageId').html(data.data);

        });
    });
</script>



</body>
</html>